/*
 * FileReader.java
 *
 * Created on 2007 7 2, 7:44
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.afaker.rss.file;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

/**
 *
 * @author new
 */
/**
 * FileReader is used to read text file,for example,txt,css,html,xml,etc.
 */
public class FileReader {
    private String filePath;
    private FileInputStream input;
    private Scanner sc;
    /** Creates a new instance of FileReader */
    public FileReader(String filePath) {
        this.filePath=filePath;
    }
    private String readFile()
    {
        String content="";
        try {
            input=new FileInputStream(filePath);
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        sc=new Scanner(input);
        while(sc.hasNext())
        {
            content+=sc.next()+"\n";            
        }
        sc.close();
        try {
            input.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        
        return content;
    }
    /**
     *@return the file's content
     */
    public String getText()
    {
        return readFile();
    }
    
}
